package chapter07

object Demo10_Tuple {
  def main(args: Array[String]): Unit = {
    //创建元组
    val tuple1 = ("hello" ,100 , true )
    println(tuple1)

    //访问元组
    println(tuple1._1)
    println(tuple1._2)
    println(tuple1._3)

    println(tuple1.productElement(1))  //根据索引位置找

    //遍历元组
    for (elem <- tuple1.productIterator) println(elem)

    //嵌套元组
    val muTuple = (12 , 0 ,3, "hello" , (22 , "java") , 99)
    println(muTuple._5._1)
  }
}
